package koction.controller;

import java.util.List;

import javax.annotation.Resource;

import koction.model.product.ProductService;
import koction.model.product.ProductVO;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class ProductController {
	@Resource(name="productServiceImpl")
	private ProductService productService;
	
	@RequestMapping("/getProductListByCategory.do")
	public ModelAndView getProductListByCategory(String category){
		List<ProductVO> list=productService.getProductListByCategory(category);
		ModelAndView mv=new ModelAndView("searchProductList.product","list",list);
		mv.addObject("category",category);
		return mv;
	}
	
	@RequestMapping("/searchProductListByName.do")
	public ModelAndView searchProductListByName(String name, String category){
		List<ProductVO> list=productService.searchProductListByName(name,category);		
		ModelAndView mv=new ModelAndView("searchProductList.product","list",list);
		mv.addObject("info",name);
		mv.addObject("category",category);
		return mv;
	}
	
	@RequestMapping("/getProductInfo.do")
	public ModelAndView getProductInfo(String productId){
		ProductVO pvo=productService.getProductInfo(productId);
		return new ModelAndView("productInfo.product","info",pvo);
	}
	
	/*@RequestMapping("/searchProductListByMaker.do")
	public ModelAndView searchProductListByMaker(String maker, String category){
		List<ProductVO> list=productService.searchProductListByMaker(maker,category);
		
		return new ModelAndView("searchProductList.product","list",list);
	}
	
	@RequestMapping("/findProductListByPrice.do")
	public ModelAndView findProductListByPrice(int min,int max,String category){
		List<ProductVO> list=productService.findProductListByPrice(min,max,category);
		return new ModelAndView("searchProductList.product","list",list);
	}*/
}
